/**
 * 逻辑运算符 and | or
 */
export enum LogicalOperator {
  And = 'AND',
  Or = 'OR'
}

export enum ComparisonOperator {
  Equal = '=',
  NotEqual = '!=',
  LessThan = '<',
  LessThanOrEqual = '<=',
  GreaterThan = '>',
  GreaterThanOrEqual = '>=',
  Like = 'LIKE',
  NotLike = 'NOT LIKE',
  IsNull = 'IS NULL',
  IsNotNull = 'IS NOT NULL'
}

/**
 * 条件表达式类型 单目 | 双目
 */
export enum ConditionExpressionType {
  Unary = 'Unary',
  Binary = 'Binary'
}

/**Ï
 * 条件表达式
 */
export interface ConditionExpression {
  '@type': 'cn.cas.imr.postgraduate.framework.common.pojo.advanced.ConditionExpression'
  id: string
  // 表达式类型
  type: ConditionExpressionType
  // 字段名
  field: string
  // 运算符
  operator: ComparisonOperator
  // 值
  value: string
}

/**
 * 单条条件项 由一个条件表达式或一组条件组成
 */
export type ConditionItem = ConditionExpression | ConditionExpressionGroup

export interface ConditionExpressionGroup {
  '@type': 'cn.cas.imr.postgraduate.framework.common.pojo.advanced.ConditionExpressionGroup'
  id: string
  logical: LogicalOperator
  conditions: ConditionItem[]
}

export interface ConditionSchema {
  label: string
  field?: string
  options?: ConditionSchema[]
}
